﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WiTeach.ClassManagement.DAL;
using WiTeach.ClassManagement.View;
using WiTeach.Tools;

namespace WiTeach.CourseManagement.View
{
    /// <summary>
    /// CoursePractiseContent.xaml 的交互逻辑
    /// </summary>
    public partial class ClassExerciseIndex : Page
    {
        public int lessonID;
        public int classHourID;
        public ClassExerciseIndex(int lessonID, int classHourID)
        {
            InitializeComponent();
            // 修改页面背景主题
            ImageBrush brush = new ImageBrush();
            brush.Stretch = Stretch.Fill;
            brush.ImageSource = new BitmapImage(new Uri(App.backgroundImage, UriKind.RelativeOrAbsolute));
            this.Background = brush;
            this.lessonID = lessonID;
            this.classHourID = classHourID;
        }

        public ClassExerciseIndex(string className)
        {
            InitializeComponent();
            // 修改页面背景主题
            ImageBrush brush = new ImageBrush();
            brush.Stretch = Stretch.Fill;
            brush.ImageSource = new BitmapImage(new Uri(App.backgroundImage, UriKind.RelativeOrAbsolute));
            this.Background = brush;
            this.exercisePageTitle.Content = className+"——练一练";
        }
        #region 导航按钮事件实现
        private void backPreLevel(object sender, RoutedEventArgs e)
        {
            this.NavigationService.GoBack(); 
        }

        private void backHome(object sender, RoutedEventArgs e)
        {
            CourseIndex courseIndex = new CourseIndex();
            this.NavigationService.Navigate(courseIndex);

        }

        #endregion

        private void ProgramWriting(object sender, RoutedEventArgs e)
        {
            ProgramWriting programWritingPage = new ProgramWriting(lessonID, classHourID);
            this.NavigationService.Navigate(programWritingPage);
 
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(".....");
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("......");
        }

        private void playVideo(object sender, RoutedEventArgs e)
        {
            FileHelper fileHelper = new FileHelper();
            string videoName = FileDAL.getVideoUrlByClassHourID(0);
            string videoFullPath = fileHelper.GetExecutionDirectoryFileFullPath("video\\", videoName);
            MediaPlay mp = new MediaPlay(videoFullPath);
            this.NavigationService.Navigate(mp);
        }

        //private void Recording(object sender, RoutedEventArgs e)
        //{
        //    Console.WriteLine("更好更好哦啊哦啊个");
        //    ProgramRecording programRecordingPage = new ProgramRecording();
        //    this.NavigationService.Navigate(programRecordingPage);
        //}

        //private void TeachingDemonstration(object sender, RoutedEventArgs e)
        //{
        //    Console.WriteLine("更好更好哦啊哦啊个");
        //}

        private void scratch_Click(object sender, RoutedEventArgs e)
        {
            string scratch_path = System.Configuration.ConfigurationManager.AppSettings["app_scratch"];
            //        System.Diagnostics.Process.Start(@arduino_path);
            try
            {
                Process scratch = new Process();
                scratch.StartInfo.FileName = scratch_path;
                scratch.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                scratch.Start();
                scratch.WaitForExit();
                scratch.Close();
                GC.Collect();
            }
            catch (Exception)
            {
            }

        }
        private void course_scratch_mouse_enter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 54;
            image.Width = 60;
        }
        private void course_scratch_mouse_leave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Image image = sender as Image;
            image.Height = 48;
            image.Width = 54;
        }

        private void anaconda_Click(object sender, RoutedEventArgs e)
        {
            string anaconda_path = System.Configuration.ConfigurationManager.AppSettings["app_anaconda"];
            //        System.Diagnostics.Process.Start(@arduino_path);
            try
            {
                Process scratch = new Process();
                scratch.StartInfo.FileName = anaconda_path;
                scratch.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                scratch.Start();
                scratch.WaitForExit();
                scratch.Close();
                GC.Collect();
            }
            catch (Exception)
            {
            }

        }
    }
}
